package com.nbers.springcloud.microservice.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;

/**
 * 资源服务-token认证
 * @author SIMON
 */
@Configuration
@EnableResourceServer//开启资源服务的功能
@EnableGlobalMethodSecurity(prePostEnabled = true)//方法级别的保护
public class ResourceServerConfiguration extends ResourceServerConfigurerAdapter {

    @Override
    public void configure(HttpSecurity http) throws Exception {
        http.authorizeRequests()
                .antMatchers("/item/**").authenticated(); // 配置order访问控制，必须认证后才可以访问
    }
}
